package cpgears.properties {
	import asunit.framework.AsynchronousTestCase;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class WidgetPropertiesBaseTest extends AsynchronousTestCase{

		private var widgetParams:XML = null;
		private var paramsObject:WidgetPropertiesBase = null;
		
		public function WidgetPropertiesBaseTest(testMethod:String = null) {
			super(testMethod);
		}

		override public function run():void {
			var request:URLRequest = new URLRequest("../test/data/widget_parameters.xml");
			var loader:URLLoader = new URLLoader();
			configureListeners(loader);
			loader.load(request);
			super.run();
		}
		
		override protected function setDataSource(event:Event):void {
			if (event != null) widgetParams = XML(event.target.data).copy();
		}

		override protected function setUp():void {
			paramsObject = new WidgetPropertiesBase();
		}
		
		public function testLoadFromString():void {
			var xmlString:String = widgetParams.toXMLString();
			paramsObject.initializeFromString(xmlString);
			assertNotNull("Param object should have an 'info' property", paramsObject.info);
			assertEquals(widgetParams.property[0].string[0].text(), paramsObject.info)
		}
		
	}

}